package org.zdw.data.structure.practice;

public class InsertPra {

    public void sort(int[] array){
       int temp = 0;
       for (int i=1; i < array.length;i++){
           //待定的插入区的最后下标值
           int j = i-1;
           //待插入的数值
           temp = array[i];
           //当待插入数值小于待插入区域的值时，插入下标向左移动并向右移动数值
           for (;j>=0 && temp < array[j];j--){
               array[j+1] = array[j];
           }

           array[j+1] = temp;
       }
    }
}
